<template>
  <div>
    <el-container>
      <el-header>
        <div>
          <img src="@/assets/logo.png" alt="" />
        </div>
        <h2>后台管理系统</h2>
        <div>
          <el-button class="tui" type="info" @click="$router.push('/')">退出</el-button>
        </div>
      </el-header>
      <el-container>
        <el-aside :width="isshow? '60px' : '200px'">
          <div class="aa" @click="isshow=!isshow">||||</div>

          <el-menu
           :collapse="isshow"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            unique-opened
            :router="true"
            :collapse-transition="false"
          >
            <el-submenu :index="item.id+''" v-for="item in menus" :key="item.id">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{item.authName}}</span>
              </template>
              <el-menu-item :index="'/'+ite.path"  v-for="ite in item.children" :key="ite.id">
                <i class="el-icon-menu"></i>
                <span slot="title">{{ite.authName}}</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import {menusApi} from '@/http/api'
export default {
  data() {
    return {
      isshow: false,
      menus:[]
    }
  },
  created(){
    // 获取权限菜单
    this.getmenus()
  },
  methods:{

    // 获取权限菜单
    getmenus(){
      menusApi().then(res=>{
        console.log('home：',res);
        this.menus=res
      })
    }
  }
};
</script>

<style lang="scss" scoped>
html,
body,
*{
  margin: 0;
  padding: 0;
}
#app {
  width: 100%;
  height: 100%;
}
.aa{
  text-align: center;
  cursor: pointer;
  height: 30px;
  align-items: center;
}
.el-menu{
  border-right: none;
}
.el-header {
  width: 100%;
  height: 60px;
  background-color: gray;
  display: flex;
  justify-content: space-between;
  color: white;
  align-items: center;
  img {
    width: 50px;
    height: 50px;
    margin-left: 10px;
  }
}
.el-container {
  width: 100%;
  height: 100%;
}
.el-aside {
  height: 100%vh;
  background-color: #666;
}
.tui{
  width: 80px;
  height: 35px;
}

.el-main{
  height: 869px;
}
</style>